﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Info_action : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string act=string.IsNullOrEmpty(Request["action"])?Request["myaction"]:Request["action"];
        if (!string.IsNullOrEmpty(act))
        {
            var bl = new Com.Ooohd.Bll.Info.ZS_Info();

            switch (act)
            {
                case "save":
                    
                    var info = bl.CreateModel();
                    info.Title = Request["title"];
                    info.CreateDate = DateTime.Now;
                    info.Area = byte.Parse(Request["area"]);
                    info.Address = Request["address"];
                    info.Category = Request["category"];
                    info.SubCategory = Request["subcategory"];
                    info.Thumn = Request["imgUrl"];
                    info.StartTime = DateTime.Parse(Request["starttime"]);
                    info.EndTime = DateTime.Parse(Request["endtime"]);
                    info.TimeDes = "";
                    info.ShortDes = Request["shortdes"];
                    info.Price = float.Parse(Request["price"]);
                    info.Detail = Request["content"];
                    if (!string.IsNullOrEmpty(Request["info_id"]))
                    {
                        info.ID = int.Parse(Request["info_id"]);
                        bl.Update(info);
                    }else
                        bl.Add(info);
                    Response.Write(Common.JSONHelper.ObjectToJSON(new { succ = true }));
                    break;
                case "get":
                    info=bl.GetSingle(int.Parse(Request["id"]));
                    info.TimeDes = info.StartTime.ToString() + "^" + info.EndTime.ToString();
                    Response.Write(Common.JSONHelper.ObjectToJSON(info));
                    break;
            }
        }
    }
}
